package com.rmb.userinfo.service.impl;

import com.rmb.mart.entity.userinfo.UserCompany;
import com.rmb.userinfo.dao.UserCompanyDao;
import com.rmb.userinfo.service.UserCompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserCompany)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 11:06:29
 */
@Service("userCompanyService")
public class UserCompanyServiceImpl implements UserCompanyService {
    @Resource
    private UserCompanyDao userCompanyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserCompany queryById(Long id) {
        return this.userCompanyDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserCompany> queryAllByLimit(int offset, int limit) {
        return this.userCompanyDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userCompany 实例对象
     * @return 实例对象
     */
    @Override
    public UserCompany insert(UserCompany userCompany) {
        this.userCompanyDao.insert(userCompany);
        return userCompany;
    }

    /**
     * 修改数据
     *
     * @param userCompany 实例对象
     * @return 实例对象
     */
    @Override
    public UserCompany update(UserCompany userCompany) {
        this.userCompanyDao.update(userCompany);
        return this.queryById(userCompany.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userCompanyDao.deleteById(id) > 0;
    }
}